/**
 */
package OBSL.impl;

import OBSL.Individual;
import OBSL.MaterialAssociationLink;
import OBSL.OBSLPackage;
import OBSL.Situation;
import OBSL.SubSituation;
import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Situation</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link OBSL.impl.SituationImpl#getName <em>Name</em>}</li>
 *   <li>{@link OBSL.impl.SituationImpl#getIndividuals <em>Individuals</em>}</li>
 *   <li>{@link OBSL.impl.SituationImpl#getMaterialAssociations <em>Material Associations</em>}</li>
 *   <li>{@link OBSL.impl.SituationImpl#getSubsituations <em>Subsituations</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class SituationImpl extends MinimalEObjectImpl.Container implements Situation {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getIndividuals() <em>Individuals</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIndividuals()
	 * @generated
	 * @ordered
	 */
	protected EList<Individual> individuals;

	/**
	 * The cached value of the '{@link #getMaterialAssociations() <em>Material Associations</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMaterialAssociations()
	 * @generated
	 * @ordered
	 */
	protected EList<MaterialAssociationLink> materialAssociations;

	/**
	 * The cached value of the '{@link #getSubsituations() <em>Subsituations</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSubsituations()
	 * @generated
	 * @ordered
	 */
	protected EList<SubSituation> subsituations;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SituationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OBSLPackage.Literals.SITUATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.SITUATION__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Individual> getIndividuals() {
		if (individuals == null) {
			individuals = new EObjectContainmentEList<Individual>(Individual.class, this, OBSLPackage.SITUATION__INDIVIDUALS);
		}
		return individuals;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<MaterialAssociationLink> getMaterialAssociations() {
		if (materialAssociations == null) {
			materialAssociations = new EObjectContainmentEList<MaterialAssociationLink>(MaterialAssociationLink.class, this, OBSLPackage.SITUATION__MATERIAL_ASSOCIATIONS);
		}
		return materialAssociations;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<SubSituation> getSubsituations() {
		if (subsituations == null) {
			subsituations = new EObjectContainmentWithInverseEList<SubSituation>(SubSituation.class, this, OBSLPackage.SITUATION__SUBSITUATIONS, OBSLPackage.SUB_SITUATION__SUPERSITUATION);
		}
		return subsituations;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.SITUATION__SUBSITUATIONS:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getSubsituations()).basicAdd(otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.SITUATION__INDIVIDUALS:
				return ((InternalEList<?>)getIndividuals()).basicRemove(otherEnd, msgs);
			case OBSLPackage.SITUATION__MATERIAL_ASSOCIATIONS:
				return ((InternalEList<?>)getMaterialAssociations()).basicRemove(otherEnd, msgs);
			case OBSLPackage.SITUATION__SUBSITUATIONS:
				return ((InternalEList<?>)getSubsituations()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OBSLPackage.SITUATION__NAME:
				return getName();
			case OBSLPackage.SITUATION__INDIVIDUALS:
				return getIndividuals();
			case OBSLPackage.SITUATION__MATERIAL_ASSOCIATIONS:
				return getMaterialAssociations();
			case OBSLPackage.SITUATION__SUBSITUATIONS:
				return getSubsituations();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OBSLPackage.SITUATION__NAME:
				setName((String)newValue);
				return;
			case OBSLPackage.SITUATION__INDIVIDUALS:
				getIndividuals().clear();
				getIndividuals().addAll((Collection<? extends Individual>)newValue);
				return;
			case OBSLPackage.SITUATION__MATERIAL_ASSOCIATIONS:
				getMaterialAssociations().clear();
				getMaterialAssociations().addAll((Collection<? extends MaterialAssociationLink>)newValue);
				return;
			case OBSLPackage.SITUATION__SUBSITUATIONS:
				getSubsituations().clear();
				getSubsituations().addAll((Collection<? extends SubSituation>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OBSLPackage.SITUATION__NAME:
				setName(NAME_EDEFAULT);
				return;
			case OBSLPackage.SITUATION__INDIVIDUALS:
				getIndividuals().clear();
				return;
			case OBSLPackage.SITUATION__MATERIAL_ASSOCIATIONS:
				getMaterialAssociations().clear();
				return;
			case OBSLPackage.SITUATION__SUBSITUATIONS:
				getSubsituations().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OBSLPackage.SITUATION__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case OBSLPackage.SITUATION__INDIVIDUALS:
				return individuals != null && !individuals.isEmpty();
			case OBSLPackage.SITUATION__MATERIAL_ASSOCIATIONS:
				return materialAssociations != null && !materialAssociations.isEmpty();
			case OBSLPackage.SITUATION__SUBSITUATIONS:
				return subsituations != null && !subsituations.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //SituationImpl
